using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NTTHAO.Common;
using NTTHAO.Web.BL.CommonPage;
using NTTHAO.CommonWeb;

public partial class admin_webparts_Plug_ins_CommonPage_CommonMenuManagement : System.Web.UI.UserControl
{
    public bool _IsAdminLogged = false;
    public CommonPageGroup _Group = null;
    public CommonMenu _Menu = null;
    public DataTable _List = null;
    public string _ReturnUrl = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        this._IsAdminLogged = "admin".Equals(Context.User.Identity.Name, StringComparison.OrdinalIgnoreCase);
        _ReturnUrl = Server.UrlEncode(Request.Url.PathAndQuery);

        int mnuid = 0;
        try
        {
            int groupID = Int32.Parse(Request.QueryString["g"].Trim());
            if (Request.QueryString["mnuid"] != null && Request.QueryString["mnuid"].Trim().Length > 0)
            {
                mnuid = Int32.Parse(Request.QueryString["mnuid"].Trim());
            }

            _Group = new CommonPageGroup(groupID);

            if (mnuid > 0)
            {
                this._Menu = new CommonMenu(mnuid);
            }

            DataSet ds = null;
            CommonMenu mnu = new CommonMenu();
            if (mnuid > 0)
            {
                ds = mnu.GetAllByParent(_Menu.ID);
            }
            else
            {
                ds = mnu.GetAllRootByGroup(groupID);
            }
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                _List = ds.Tables[0];
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message + "<br /><br />" + ex.StackTrace);
        }
    }
}
